<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>使数组变成交替数组的最少操作数</title>
</head>
<body>
  <script>
    function fn(nums) {
      let res = 0;
      for (let i = 0; i < nums.length; i++) {
        if (i % 2 === 0 && nums[i] % 2 === 0) {
          res++;
        } else if (i % 2 !== 0 && nums[i] % 2 !== 0) {
          res++;
        }
      }
      return res
    }
    console.log(fn([3, 1, 3, 2, 4, 3]))
  </script>
</body>
</html>